package com.doys.myfirstapp.u8;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.U8.operation.U8Series;
import com.U8.reader.model.InventoryBuffer;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * 读写界面
 */
@SuppressLint("ValidFragment")
public class ReadAndWriteFragment extends Fragment implements OnClickListener {

	private Context mContext;

	private TextView mRead, mWrite, mLock, mKill;// mGet, mSelect,

	private EditText returnData;

	private Spinner mTagEpcListSpinner;

	private List<String> list;
	private ArrayAdapter<String> adapter;

	private EditText mPasswordEditText;
	private EditText mStartAddrEditText;
	private EditText mDataLenEditText;

	private EditText mDataEditText;
	private EditText mLockPasswordEditText;
	private EditText mKillPasswordEditText;
	private RadioGroup mGroupAccessAreaType;
	private RadioGroup mGroupLockAreaType;
	private RadioGroup mGroupLockType;
	private boolean flag=false;
    private static long readTimeOut = 10*60*1000;

	// public static boolean haveSetEPC;

	private U8Series mUSeries;

	public static enum rwBlock {
		ACSESSPRASSWORD, KILLPRASSWORD, EPC, TID, USER
	}

	public ReadAndWriteFragment(Context context) {
		this.mContext = context;
	}

	public ReadAndWriteFragment() {
	}
	@Override
	public void onResume() {
		super.onResume();
	};

	@Override
	public void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mUSeries = U8Series.getInstance();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		return null;
	}

	@Override
	public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		mTagEpcListSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//				String strEPC = mTagEpcListSpinner.getSelectedItem().toString();
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub
			}
		});
		mRead.setOnClickListener(this);
		mWrite.setOnClickListener(this);
		mLock.setOnClickListener(this);
		mKill.setOnClickListener(this);
	}

	@Override
	public void onDestroy() {
		super.onDestroy();

	}

	public void addEpcList(Context context, InventoryBuffer m_curInventoryBuffer) {

//		list.clear();
//		list.add("Cancel");
//		for (int i = 0; i < m_curInventoryBuffer.lsTagList.size(); i++) {
//			list.add(m_curInventoryBuffer.lsTagList.get(i).strEPC);
//		}
//		adapter.notifyDataSetChanged();
//		mTagEpcListSpinner.setSelection(0);
	}
	int i=0;
	@Override
	public void onClick(View arg0) {}

}
